package org.eenie.qeasy;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class ConfigActivity extends AppCompatActivity implements TimeTrack.OnTriggerListener {
    TimeTrack mTimeTrack;
    List<PulseConfig> mPulseConfigs = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);

        mTimeTrack = findViewById(R.id.time_track);

        mPulseConfigs.add(new PulseConfig(5, 10, "080701010180"));
        mPulseConfigs.add(new PulseConfig(18, 10, "080701010180"));
        mPulseConfigs.add(new PulseConfig(45, 5, "080701010180"));

        mTimeTrack.setPulseConfigs(mPulseConfigs);
        mTimeTrack.setTotalTime(120);
        mTimeTrack.setTriggerListener(this);

        findViewById(R.id.btn_start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mTimeTrack.start();
            }
        });

    }

    @Override
    public void onTrigger(PulseEntity entity) {
        if (entity.getPulseMode() == PulseMode.START) {
            System.out.println("come in");
        } else {
            System.out.println("come out");
        }
    }

    @Override
    public void onTimeChange(float time) {

    }
}
